﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<ChoViet.CMS.ViewModels.CommentCmsViewModels>" %>
<%@ Import Namespace="ChoViet.Lib.Helpers" %>
<%@ Import Namespace="ChoViet.Lib.Paging" %>
<%@ Import Namespace="ChoViet.CMS.Controllers" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Quản lý bình luận
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%if(ViewData["MessageInfo"]==null){ %>
	<form action="/Comment/IndexCms" method="post" name="adminForm">
		<table width="100%">
			<tr>
			    <td align="left">
			        Tìm nhanh <%= Html.TextBox("Keyword", Model.Keyword) %>
			        <%= Html.ActionImageJS("Tìm kiếm", "icon-32-search.png", "document.adminForm.submit();", false)%>
			    </td>
				<td align="right">
				    <%=Html.DropDownList("TypePubYN", new SelectList(Model.ListPubYN, "Key", "Value", Model.CurrentPubYN).ToList(), "--Trạng thái kích hoạt --", new { onchange = "document.adminForm.submit();" })%>				    
			    </td>
			</tr>
		</table>
		<table width="100%" class="adminlist">
		    <thead>
			<tr>
				<th width="30" align="right">
					STT
				</th>
				<th width="30">
				</th>
				<th align ="center">
					 <%= Html.Sort("Tiêu đề bình luận", "Title", ViewData["orderDir"].ToString(), ViewData["order"].ToString())%>
					 Có <%=Model.ListComment.TotalItemCount%> bình luận trong danh sách
				</th>
				<th>
				  Bình luận của tin rao
				</th>
				<th width="100" align="center">
					 <%= Html.Sort("Thời gian", "CreatedDate", ViewData["orderDir"].ToString(), ViewData["order"].ToString())%>
				</th>
				<th width="80" align ="center">
					Publish
				</th>
				<th style="width: 40px">
                    <%= Html.Sort("ID", "ID", ViewData["orderDir"].ToString(), ViewData["order"].ToString())%>
                </th>
			</tr>
			</thead>
			<tbody>
		<% 
			int i = 0;
    		foreach (var item in Model.ListComment) {
				i++;
		%>
			<tr id="tr_<%=item.ID%>">
				<td align="right">
					<%= i.ToString() %>
				</td>
				 <td align="center">
					<img alt="Xóa giá trị" src="/Images/icon-24-delete.png" onclick="DelComment(<%=item.ID %>);" />
				</td>
				<td>
				    <a href="/Comment/DetailsCms/<%=item.ID%>" title="<%=item.Title %>"><%=string.IsNullOrEmpty(item.Title) ? "Bình luận ko có tiêu đề" : item.Title%></a>
				</td>
				<td>
				    <a href="/Ad/DetailsCms/<%=item.Ad.ID%>"><%=item.Ad.Title%></a>
				</td>
				<td align="center">
				    <%= string.Format("{0:dd/MM/yyyy HH:mm}",item.CreatedDate)%>
				</td>
				<td align="center">
                    <img alt="" id="imgPubYN_<%= item.ID %>" onclick="ChangePubYN(<%= item.ID %>);" value="<%= item.PublishYN.HasValue ? item.PublishYN.Value : false %>"
                        src="<%= item.PublishYN.HasValue && item.PublishYN.Value==true ? "/Images/icon-32-apply.png" : "/Images/icon-32-cancel.png" %>" />
                </td>
				<td align="center">
				<%=Html.Encode(item.ID) %>
				</td>
			</tr>
		<% } %>
        </tbody>
		</table>
		<%= Html.Hidden("order")%>
		<%= Html.Hidden("orderDir")%>
		<table width="100%">
            <tr>
                <td align="center">
             
                <div class="pager">
                <label>Hiển thị #</label>
                    <%
                        int[] pageSizeList = {1, 5, 10, 15, 20, 25, 50, 100};
                    %>
                    <%= Html.DropDownList("PageSize", new SelectList(pageSizeList, Model.ListComment.PageSize), new { onchange = "document.adminForm.submit();" })%>

                    <%= Html.Pager(Model.ListComment.PageSize, Model.ListComment.PageNumber, Model.ListComment.TotalItemCount)%>
                </div>
                </td>
            </tr>
        </table>
	</form>
 <% } %>
  <script type="text/javascript">
        function ChangePubYN(id) {
            var obj = $("#imgPubYN_" + id);
            ApplyChangeYN("/Applications/ApplyChangeYN/ApChangeYN/" + "Comment" + '/' + "PublishYN" + '/' + id + '/' + obj.attr("value"), id, obj);
        }
        function DelComment(id) {
            Del(id, 'Comment');
        }  
    </script>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="Toolbar" runat="server">
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="Header" runat="server">
Quản lý bình luận
</asp:Content>

<asp:Content ID="Content5" ContentPlaceHolderID="Message" runat="server">
<%=ViewData["MessageInfo"]!=null? "<p class='perror'>"+Html.Encode(ViewData["MessageInfo"])+"</p>":string.Empty%>  
</asp:Content>
